﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Homework_2
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create and add value to the 3 main string that will be sent into the custom commands getName,getAge,getGender
            string uName = " ";
            int uAge = 0;
            string uGender = " ";
            print("Logic and Programming Class\nCreate custom commands and\nSave string, int, and char values.");
            //call the commands with their respective string to be used
            getName(ref uName);
            getAge(ref uAge, uName);
            getGender(ref uGender);
            //Display info before and after making a change
            Info:
            print("Thank You, you have provided the following data:\n");
            Console.WriteLine("Name: {0}\nAge: {1}\nGender: {2}\n", uName, uAge, uGender);
            Console.WriteLine("To change your Name: type \"Name\"\nTo change your Age: type \"Age\"\nTo change your Gender: \"Gender\"\nIf you dont want to make any changes just type \"Done\".", uName, uAge, uGender);
            string uSubmit = Console.ReadLine();
            //Ask the user if they would like to make a change or complete the 'program'
            if (uSubmit == "Name" || uSubmit == "name")
            {
                getName(ref uName);
                goto Info;
            }
            else if (uSubmit == "Age" || uSubmit == "age")
            {
                getAge(ref uAge, uName);
                goto Info;
            }
            else if (uSubmit == "Gender" || uSubmit == "gender")
            {
                getGender(ref uGender);
                goto Info;
            }
            else if (uSubmit == "Done" || uSubmit == "done")
            {
                //Console.WriteLine("\nThe data you have provided is as follows:\nName: {0}\nAge: {1}\nGender: {2}\n", uName, uAge, uGender);
            }
            else
            {
                goto Info;
            }
            print("END OF THE PROGRAM");
        }
        static void getName(ref string uName)
        {
            char tok = ' ';
            Namae:
            print("Please provide your Name, First and Last only:");
            uName = Console.ReadLine();
            if (!uName.Contains(tok))
            {
                print("Invalid Name!");
                goto Namae;
            }
            string[] vName = uName.Split(tok);
            if (vName[0].Length < 3 || vName[1].Length < 3)
            {
                print("Invalid Name!");
                goto Namae;
            }
            Console.WriteLine("Thank You {0}",vName[0]);
        }
        static void getAge(ref int uAge, string uName)
        {
        Age:
            print("Please provide your age:");
            string uAgeVerify;
            while (!int.TryParse(Console.ReadLine(), out uAge))
            {
                print("You have provided an invalid Age, please provide your age as Years with no decimals.");
            }
            if (uAge < 18 || uAge > 75)
            {
            Age2:
                Console.WriteLine("{0} Is your Age really {1}? Y or N?", uName, uAge);
                uAgeVerify = Console.ReadLine();
                if (uAgeVerify == "Y" || uAgeVerify == "y")
                {
                    print("OK, we will continue now.");
                }
                else if (uAgeVerify == "N" || uAgeVerify == "n")
                {
                    goto Age;
                }
                else goto Age2;
            }
        }
        static void getGender(ref string uGender)
        {
            Gender:
            print("Please provide your Gender: \"M\" or \"Male\",\"F\" or \"Female\"");
            uGender = Console.ReadLine();
            if (uGender == "M" || uGender == "m" || uGender == "Male" || uGender == "male")
            {
                uGender = "Male";
            }
            else if (uGender == "F" || uGender == "f" || uGender == "Female" || uGender == "female")
            {
                uGender = "Female";
            }
            else
            {
                print("Invalid answer!");
                goto Gender;
            }
        }
        static void print(string text)
        {
            Console.WriteLine("\n{0}",text);
        }
    }
}
